package com.weiyi.digitaloperatingroom;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import com.weiyi.digitaloperatingroom.Bean.LoginResult;
import com.wjr.braveheart.http.GoHttp;
import com.wjr.braveheart.http.callback.HttpCallback;
import com.wjr.braveheart.ui.activity.AppActivity;
import com.wjr.braveheart.utils.GsonUtils;
import com.wjr.braveheart.utils.LogUtils;

import java.util.List;

public class LoginActivity extends AppActivity {

    private EditText user_name_et, pass_word_et;
    private Button btn_login;

    @Override
    protected int bindLayoutId() {
        return R.layout.activity_login;
    }

    @Override
    protected void initEventAndData(Bundle savedInstanceState, Bundle extras) {
        btn_login = getView(R.id.btn_login);
        btn_login.setOnClickListener(this);
    }

    @Override
    protected void loadData() {

    }

    @Override
    protected void onWidgetClick(View view) {
        switch (view.getId()) {
            case R.id.btn_login:
                GoHttp.create(this)
                        .get()
                        .url(Api.USER_SIGNIN_INFO)
                        .addParam("User_NO", "super")
                        .addParam("User_PSW", "super")
                        .execute(new HttpCallback<LoginResult>() {
                            @Override
                            public void onError(Exception e) {
                                startActivity(MainActivity.class);
                                LogUtils.e(e.getMessage());
                            }

                            @Override
                            public void onSuccess(LoginResult result) {
                                startActivity(MainActivity.class);
                                List<LoginResult.LoginBean> loginBeans = GsonUtils.GsonToList(result.getData(), LoginResult.LoginBean.class);
                                LogUtils.e(loginBeans.toString());
                            }
                        });
                break;
        }
    }
}
